package com.bjpowernode.settings.test;

import com.bjpowernode.crm.exception.LoginException;
import com.bjpowernode.crm.setting.domain.User;
import com.bjpowernode.crm.setting.service.UserService;
import com.bjpowernode.crm.setting.service.impl.UserServiceImpl;
import com.bjpowernode.crm.utils.DateTimeUtil;
import com.bjpowernode.crm.utils.MD5Util;
import com.bjpowernode.crm.utils.ServiceFactory;
import com.bjpowernode.crm.utils.UUIDUtil;
import com.bjpowernode.crm.workbench.domain.Activity;
import com.bjpowernode.crm.workbench.service.ActivityService;
import com.bjpowernode.crm.workbench.service.impl.ActivityServiceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class test1 {

    public static void main(String[] args) {


        //验证失效时间
        //失效时间
        /*String expireTime = "2019-10 10:10:10";
        //当前系统时间
        String currentTime = DateTimeUtil.getSysTime();
        int count = expireTime.compareTo(currentTime);
        System.out.println(count);*/

        /*String lockState = "0";
        if ("0".equals(lockState)) {
            System.out.println("账号已锁定");
        }*/

        //验证浏览器ip地址
        /*String ip = "192.168.1.3";
        String allowIps = "192.168.1.1,192.168.1.2";

        if (allowIps.contains(ip)) {
            System.out.println("ip地址有效,允许访问");
        } else {
            System.out.println("ip地址受限,请联系管理员");
        }*/

        /*String pwd = "124";
        pwd = MD5Util.getMD5(pwd);
        System.out.println(pwd);*/

        String loginAct = "zs";
        String pwd = "123";
        pwd = MD5Util.getMD5(pwd);
        String ip = "192.168.1.1";

        UserService us = (UserService) ServiceFactory.getService(new UserServiceImpl());
        //try {
        //    User user = us.login(loginAct, pwd, ip);
        //    System.out.println(user);
        //} catch (LoginException e) {
        //    e.printStackTrace();
        //}

        List<User> userList = us.getUserList();

        for (User user : userList) {
            System.out.println(user);
        }

        ActivityService as = (ActivityService) ServiceFactory.getService(new ActivityServiceImpl());
        String id = UUIDUtil.getUUID();
        //创建时间,当前的系统时间
        String createTime = DateTimeUtil.getSysTime();
        //创建人,当前登录的用户

        Activity a = new Activity();
        a.setId(id);
        //a.setCost(cost);
        //a.setCreateBy(createBy);
        //a.setCreateTime(createTime);
        //a.setDescription(description);
        //a.setName(name);
        //a.setOwner(owner);
        //a.setStartDate(startDate);
        //a.setEndDate(endDate);

        Boolean f = as.save(a);
        System.out.println(f);

    }
}












